/**
 * 
 */
package com.alphasystem.commerce.common.model.locale;

import static javax.persistence.InheritanceType.JOINED;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.ManyToMany;
import javax.persistence.Table;

/**
 * @author Syed Farhan Ali
 * 
 */
@Entity
@Table(name = "LANGUAGE")
@Inheritance(strategy = JOINED)
public class Language extends LocaleEntity {

	private static final long serialVersionUID = -3127119334353445496L;

	protected Set<Country> countries;

	protected String languageCode;

	public Language() {
		this(TEMP_ID, TEMP_ID);
	}

	public Language(String languageCode, String name) {
		super(languageCode);
		this.languageCode = languageCode;
		this.name = name;
	}

	@ManyToMany(mappedBy = "languages", fetch = FetchType.EAGER)
	public Set<Country> getCountries() {
		return countries;
	}

	@Column(name = "language_code", length = 2, nullable = false, unique = true)
	public String getLanguageCode() {
		return languageCode;
	}

	public void setCountries(Set<Country> countries) {
		this.countries = countries;
	}

	public void setLanguageCode(String languageCode) {
		this.languageCode = languageCode;
	}

	@Override
	public String toString() {
		return "Language: " + languageCode + "-" + name;
	}

}
